#pragma once
#include "Common.h"

template<int BITS>
class TCMalloc_PageMap1 {
private:
	static const int LENTH = 1 << BITS;
	void** _array;
public:
	typedef uintptr_t Number;

	explicit TCMalloc_PageMap1() {
		size_t size = sizeof(void*) << BITS;
		size_t align_size = SizeClass::RoundUp(size);
		_array = (void**)SystemAlloc(align_size >> PAGE_SHIFT);
		memset(_array, 0, size);
	}

	void* Get(Number k) {
		if ((k >> BITS) > 0) {
			return nullptr;
		}
		return _array[k];
	}

	void Set(Number k, void* v) {
		_array[k] = v;
	}
};
